package cn.stylefeng.roses.kernel.pay.modular.controller;

import cn.stylefeng.roses.kernel.pay.modular.entity.Goods;
import cn.stylefeng.roses.kernel.pay.modular.pojo.GoodsRequest;
import cn.stylefeng.roses.kernel.pay.modular.service.GoodsService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品信息控制器
 *
 * @author stylefeng
 * @date 2021/06/23 22:28
 */
@RestController
@ApiResource(name = "商品信息")
public class GoodsController {

    @Resource
    private GoodsService goodsService;

    /**
     * 获取列表
     *
     * @author stylefeng
     * @date 2021/06/23 22:28
     */
    @GetResource(name = "获取商品列表", path = "/goods/list", requiredLogin = false, requiredPermission = false)
    public ResponseData<List<Goods>> list(GoodsRequest goodsRequest) {
        return new SuccessResponseData<>(goodsService.findList(goodsRequest));
    }

    /**
     * 查看详情
     *
     * @author stylefeng
     * @date 2021/06/23 22:28
     */
    @GetResource(name = "查看详情", path = "/goods/detail", requiredLogin = false, requiredPermission = false)
    public ResponseData<Goods> detail(@Validated(GoodsRequest.detail.class) GoodsRequest goodsRequest) {
        return new SuccessResponseData<>(goodsService.detail(goodsRequest));
    }

}
